package com.servicesDirectory.action.programme;

import java.util.List;


import com.opensymphony.xwork2.ActionSupport;
import com.servicesDirectory.common.vo.BaseProgrammeVO;
import com.servicesDirectory.dao.programme.BaseProgrammeDAOImpl;

public class ProgrammeAction extends ActionSupport {
	/**
	 * 
	 */

	private static final long serialVersionUID = 1L;
	
	public int programmeID;
	String programmeName;
	
	String description;
	String contactName;
	public int isActive;

	public BaseProgrammeDAOImpl dao = null;
	public BaseProgrammeVO programmeVO;
	public List<BaseProgrammeVO> programmeList;
	public String filter = "";
	private boolean checkActive;
    private boolean checkInclude;
    
//	@Override
//	public void validate() {
//			addActionError(programmeVO.toString());
//	}
    public String listProgramme() {
        dao = new BaseProgrammeDAOImpl();
        programmeList = dao.getProgrammeListFilter(filter, checkInclude);
        return SUCCESS;
    }
    
	public int getProgrammeID() {
		return programmeID;
	}

	public String getFilter() {
		return filter;
	}

	public void setFilter(String filter) {
		this.filter = filter;
	}

	public boolean isCheckActive() {
		return checkActive;
	}

	public void setCheckActive(boolean checkActive) {
		this.checkActive = checkActive;
	}

	public boolean isCheckInclude() {
		return checkInclude;
	}

	public void setCheckInclude(boolean checkInclude) {
		this.checkInclude = checkInclude;
	}

	public String getProgrammeName() {
		return programmeName;
	}

	public void setProgrammeName(String programmeName) {
		this.programmeName = programmeName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}


	public String getContactName() {
		return contactName;
	}

	public void setContactName(String contactName) {
		this.contactName = contactName;
	}

	public int getIsActive() {
		return isActive;
	}

	public void setIsActive(int isActive) {
		this.isActive = isActive;
	}

	public void setProgrammeID(int programmeID) {
		this.programmeID = programmeID;
	}

	@Override
	public String execute() {
		return "success";
	}

	public String insert() {
		dao = new BaseProgrammeDAOImpl();
		if (dao.insertProgramme(programmeVO)) {
			return SUCCESS;
		} else
			return "error";
	}

	public String fetch() {
		dao = new BaseProgrammeDAOImpl();
		programmeList = dao.searchProgramme(getProgrammeID());
		return SUCCESS;
	}

	public String update() {
		dao = new BaseProgrammeDAOImpl();
		
		programmeVO = new BaseProgrammeVO(getProgrammeID(), getProgrammeName(), getDescription(),""+getIsActive(), getContactName());
		if (dao.updateProgramme(programmeVO)) {
			return SUCCESS;
		} else {
			return "error";
		}

	}

	public String delete() {
		dao = new BaseProgrammeDAOImpl();
		if (dao.deleteProgramme(getProgrammeID())) {
			return SUCCESS;
		} else
			return "error";
	}

	public static void main(String[] args) {
		ProgrammeAction action = new ProgrammeAction();
		// List<BaseProgrammeVO> base = dao.getProgrammeList();
		System.out.println(action.getProgrammeID());

		// System.out.println(base.get(0).getProgrammeName());
		// System.out.println(dao.insertProgramme("PRO07", "GAME07"));
	}

	public BaseProgrammeVO getProgrammeVO() {
		return programmeVO;
	}

	public void setProgrammeVO(BaseProgrammeVO programmeVO) {
		this.programmeVO = programmeVO;
	}

	public List<BaseProgrammeVO> getProgrammeList() {
		return programmeList;

	}

	public void setProgrammeList(List<BaseProgrammeVO> programmeList) {
		this.programmeList = programmeList;
	}


}
